
/*
剑指 Offer 11. 旋转数组的最小数字
解题思路：二分查找算法
 */

public class Offer11 {

  public static int minArray(int[] numbers) {
    int left = 0;
    int right = numbers.length - 1;
    while (left < right){
      int mid = left + (right - left)/2;
      if (numbers[mid] < numbers[right] ){
        right = mid;
      }else if (numbers[mid] > numbers[right]){
        left = mid + 1;
      }else {
        right = right - 1;
      }
    }
    return numbers[left];
  }

  public static void main(String[] args) {

    int []num = new int[]{3,4,5,1,5};
    System.out.println(Offer11.minArray(num));
  }
}
